{include('Layout/header')}
<div class="row row-bgcolor">
    <div class='col-md-12 content-title'>
        <h3>添加用户</h3>
    </div>
    <div class='col-md-6 content col-md-offset-3'>
        <form action="{\Rexzy::url('admin/uaddact')}" method="post">
            <div class="form-group">
                <label for="name">用户名</label>
                <input type="text" class="form-control" id="name" name="name" placeholder="用户名" >
                <p id="name_note" class="input-note">请输入4-16个字符的用户名，用于用户登录</p>
            </div>
            <div class="form-group">
                <label for="screenName">昵称</label>
                <input type="text" class="form-control" id="screenName" name="screenName"  >
                <p id="screenName_note" class="input-note">可用于前台显示，为空时默认为用户名</p>
            </div>
            <div class="form-group">
                <label for="password">密码</label>
                <input type="password" class="form-control" id="password" name="password" placeholder="密码">
                <p id="password_note" class="input-note">请输入6-20个字符的密码</p>
            </div>
            <div class="form-group">
                <label for="confPassword" >密码确认</label>
                <input type="password" class="form-control" id="confPassword" name="confPassword" placeholder="Confirm Password">
                <p id="confPassword_note" class="input-note">请确认你的密码, 与上面输入的密码保持一致</p>
            </div>
            <div class="form-group">
                <label for="mai1">电子邮箱地址</label>
                <input type="email" class="form-control" id="mail" name="mail">
                <p id="mail_note" class="input-note">请输入电子邮箱地址</p>
            </div>
            <div class="form-group">
                <label for="grop">用户组</label>
                <select name="group" id="group" class="form-control user-group">
                    <option value="subscriber">关注者</option>
                    <option value="contributor">贡献者</option>
                    <option value="editor">编辑</option>
                    <option value="administrator">管理员</option>
                </select>
                <p id="mail_note" class="input-note">不同的用户组拥有不同的权限.</p>
            </div>
            <button type="submit" class="btn btn-info add-btn">添加</button>
        </form>
    </div>
</div>

<script>

// 表单验证，提交成功后跳转函数
function checkLocation() {
    location = "{\Rexzy::url('admin/userlist')}";
}

//触发表单验证
formVerification( 'form', [
    {
        id: 'name',
        required: true,
        errormessage: '请输入用户名',
        rules:[
            {
                rule:function( val) {
                if ( ( val.length < 4 ) || (val.length >16 ) ) {
                    return false;
                }
                },
                error: "请输入4-16个字符的用户名",
            }
        ]
    },
    {
        id: 'password',
        required: true,
        errormessage: '请输入密码', 
        rules:[
            {
                rule:function( val) {
                    if ( val.length < 4 ) {
                        return false;
                    }
                },
                error: "请输入4个或以上字符的密码",
            }
        ]
    },
    {
        id: 'confPassword',
        required: true,
        errormessage: '请输入密码', 
        rules:[
            {
                rule:function(val) {
                    if ( val !== $("#password" ).val() ) {
                        return false;
                    }
                },
                error: "密码不一致"
            }
        ]
    }, 
    {
        id: 'screenName',
        required: false
    },
    {
        id: 'mail',
        require: false,
    },
    {
        id: 'group',
        require: true,
    }
],checkLocation );       
        
</script>

{include('Layout/footer')}